package com.qzsoft.zhjd.laboratory.modules.asphaltLowTemperatureElongation.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qzsoft.jeemis.common.exception.RenException;
import com.qzsoft.zhjd.common.components.BaseServiceComponent;
import com.qzsoft.zhjd.common.model.*;
import com.qzsoft.zhjd.common.utils.AsphaltProtocolParserUtils;
import com.qzsoft.zhjd.common.utils.DuctilityYjkjDataParserUtils;
import com.qzsoft.zhjd.common.utils.ZhjdIotUtils;
import com.qzsoft.zhjd.laboratory.modules.asphaltLowTemperatureElongation.entity.AsphaltLowTemperatureElongationEntity;
import com.qzsoft.zhjd.laboratory.modules.asphaltLowTemperatureElongation.entity.AsphaltLowTemperatureElongationResEntity;
import com.qzsoft.zhjd.laboratory.modules.asphaltLowTemperatureElongation.mapper.AsphaltLowTemperatureElongationMapper;
import com.qzsoft.zhjd.laboratory.modules.asphaltLowTemperatureElongation.mapper.AsphaltLowTemperatureElongationResMapper;
import com.qzsoft.zhjd.laboratory.modules.asphaltLowTemperatureElongation.service.AsphaltLowTemperatureElongationResService;
import com.qzsoft.zhjd.laboratory.modules.asphaltLowTemperatureElongation.service.AsphaltLowTemperatureElongationService;
import com.qzsoft.zhjd.laboratory.modules.asphaltSofteningPoint.entity.AsphaltSofteningPointResEntity;
import com.qzsoft.zhjd.laboratory.modules.errorRecord.service.ErrorRecordService;
import com.qzsoft.zhjd.laboratory.modules.marshallStabilityNew.entity.MarshallStabilityNewEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.stream.Collectors;


@Service("asphaltLowTemperatureElongationService")
public class AsphaltLowTemperatureElongationServiceImpl extends ServiceImpl<AsphaltLowTemperatureElongationMapper, AsphaltLowTemperatureElongationEntity> implements AsphaltLowTemperatureElongationService {

    @Autowired
    private AsphaltLowTemperatureElongationMapper asphaltLowTemperatureElongationMapper;

    @Autowired
    private AsphaltLowTemperatureElongationResMapper resMapper;

    @Autowired
    private BaseServiceComponent baseServiceComponent;

    @Autowired
    private AsphaltLowTemperatureElongationResService asphaltLowTemperatureElongationResService;

    @Autowired
    private ErrorRecordService errorRecordService;

    private static Map<String,String> currentMap = new HashMap<>();

    /**
     * 列表
     */
    @Override
    public IPage<JSONObject> queryPage(Map<String, Object> params) {
        IPage<AsphaltLowTemperatureElongationEntity> page = baseServiceComponent.getPage(params, AsphaltLowTemperatureElongationEntity.class);
        return asphaltLowTemperatureElongationMapper.queryPage(page, params);
    }

    /**
     * 信息
     *
     * @return AsphaltLowTemperatureElongationEntity
     */
    @Override
    public AsphaltLowTemperatureElongationEntity getInfo(String id) {
        return getById(id);
    }

    /**
     * 保存
     */
    @Override
    public void saveData(AsphaltLowTemperatureElongationEntity asphaltLowTemperatureElongation) {
        save(asphaltLowTemperatureElongation);
    }

    /**
     * 修改
     */
    @Override
    public void updateData(AsphaltLowTemperatureElongationEntity asphaltLowTemperatureElongation) {
        updateById(asphaltLowTemperatureElongation);
    }

    /**
     * 删除单条数据
     *
     * @param id
     */
    @Override
    public void deleteOneData(String id) {
        removeById(id);
    }

    /**
     * 删除
     */
    @Override
    public void deleteData(List<String> ids) {
        removeByIds(ids);
    }


    /**
     * 解析沥青低温延伸度试验仪数据 三标航天科宇设备v2.X
     * @param resData  试验结果数据
     * @param deviceId 试验设备id
     *  示例：
     * FAFBFC——数据开头标志
     * 0F——数据长度
     * A7——结果数据
     * 0450——length1，1104mm;
     * 0457——length2，1111mm;
     * 045D——length3，1117mm;
     * 0000——拉力峰值1，1位小数，0.0；
     * 0000——拉力峰值2，1位小数，0.0；
     * 0000——拉力峰值3，1位小数，0.0；
     * 07——状态，通道1，通道2，通道3数据都有效；
     * BE——校验和 ，
     *
     * FAFBFC——数据开头标志
     * 15——数据字节长度；
     * A4——过程数据，
     * 00——flag，0无效数据，1试验数据；
     * 0000——位移量Legth3，单位mm
     * 0000——位移量Legth3，单位mm
     * 0000——位移量Legth3，单位mm
     * 32——延伸速率SPEED，单位mm/min，50mm/min;
     * 05EB——当前温度，两位小数，15.15℃
     * 05DC——设定温度，两位小数，15.00℃；
     * 0000——拉力瞬时值1，一位小数，0.0
     * 0000——拉力瞬时值2，一位小数，0.0
     * 0000——拉力瞬时值3，一位小数，0.0
     * 47——仪器状态，01000111，控温状态开启，加热状态开启，起点限位状态有效，终点限位状态无效，电机状态拉伸运动中无效，电机状态向回退运动中无效，内循环水泵开启中，保留0；
     * F4——校验和
     */
    @Override
    public void parsingData(String resData, String deviceId) {
        Date nowDate = new Date();
        try {
            List<String> dataList = ZhjdIotUtils.analyzeExperimentalData(resData);
            //如果数据以00开头，可能设备刚开机或重启，表示一次新的实验开始
            if(StringUtils.equals(dataList.get(0),"00")){
                currentMap.remove(deviceId);
            }
            //验证位不进行校验
            int i = 4;
            //试验数据
            if (StringUtils.equals(ZhjdIotUtils.DATA_TYPE_TEST, dataList.get(i))) {
                AsphaltLowTemperatureElongationEntity entity = new AsphaltLowTemperatureElongationEntity();
                entity.setDeviceId(deviceId);
                if(currentMap.get(deviceId) == null){
                    AsphaltLowTemperatureElongationResEntity resEntity = new AsphaltLowTemperatureElongationResEntity();
                    resEntity.setDeviceId(deviceId);
                    asphaltLowTemperatureElongationResService.save(resEntity);
                    currentMap.put(deviceId,resEntity.getId());
                }
                //设置实验结果数据id
                entity.setResId(currentMap.get(deviceId));
                entity.setOriginalData(resData);
                entity.setCreateTime(nowDate);
                i++;
                entity.setFlag(dataList.get(i));

                // 将16进制转换为10进制数据，不含（0x）
                // 位移量Length1,Legth2,Legth3
                i++;
                BigDecimal length1 = ZhjdIotUtils.hexToTwoPoint(dataList.get(i)+dataList.get(i + 1));
                entity.setLength1(length1);
                i += 2;
                BigDecimal length2 = ZhjdIotUtils.hexToTwoPoint(dataList.get(i)+dataList.get(i + 1));
                entity.setLength2(length2);
                i += 2;
                BigDecimal length3 = ZhjdIotUtils.hexToTwoPoint(dataList.get(i)+dataList.get(i + 1));
                entity.setLength3(length3);
                i +=2 ;
                //延伸速率SPEED。 取值：10  50 表示为10mm/min 和50mm/min
                Integer speed1 = Integer.parseInt(dataList.get(i), 16);
                entity.setSpeed1(speed1);
                i++;
                //温度 当前温度值CURR_TEMP，高8位在前。2字节有符号整形，取值-32768~+32767，含2位小数 TODO:正负数处理
                //TODO
                entity.setCurrTemp(ZhjdIotUtils.hexToTwoPoint(dataList.get(i)+dataList.get(i + 1)));
                //设定的温度值SET_TEMP，高8位在前。2字节有符号整形，取值-32768~+32767，含2位小数。
                //TODO
                i += 2;
                entity.setSetTemp(ZhjdIotUtils.hexToTwoPoint(dataList.get(i) + dataList.get(i + 1)));
                //拉力瞬时值F1,F2,F3含一位小数；
                i+=2;
                entity.setLali1(ZhjdIotUtils.hexToOnePoint(dataList.get(i)+dataList.get(i+1)));
                i+=2;
                entity.setLali2(ZhjdIotUtils.hexToOnePoint(dataList.get(i)+dataList.get(i+1)));
                i+=2;
                entity.setLali3(ZhjdIotUtils.hexToOnePoint(dataList.get(i)+dataList.get(i+1)));
                //仪器状态
                i+=2;
                entity.setStatus(dataList.get(i));
                save(entity);
                //结果数据
            } else if (StringUtils.equals(ZhjdIotUtils.DATA_TYPE_RES, dataList.get(i))) {
                AsphaltLowTemperatureElongationResEntity resEntity = new AsphaltLowTemperatureElongationResEntity();
                resEntity.setId(currentMap.get(deviceId));
                currentMap.remove(deviceId);
                resEntity.setDeviceId(deviceId);
                resEntity.setOriginalData(resData);
                resEntity.setCreateTime(nowDate);
                // 将16进制转换为10进制数据，不含（0x）
                // 位移量Length1,Legth2,Legth3
                i++;
//                BigDecimal length1 = ZhjdIotUtils.hextot(dataList.get(i), dataList.get(i + 1));
                resEntity.setLength1(new BigDecimal(Integer.parseInt(dataList.get(i)+dataList.get(i+1),16)));
                i += 2;
//                BigDecimal length2 = ZhjdIotUtils.hexToDecimalism(dataList.get(i), dataList.get(i + 1));
                resEntity.setLength2(new BigDecimal(Integer.parseInt(dataList.get(i)+dataList.get(i+1),16)));
                i += 2;
//                BigDecimal length3 = ZhjdIotUtils.hexToDecimalism(dataList.get(i), dataList.get(i + 1));
                resEntity.setLength3(new BigDecimal(Integer.parseInt(dataList.get(i)+dataList.get(i+1),16)));
                i += 2;
                resEntity.setLali1(ZhjdIotUtils.hexToOnePoint(dataList.get(i)+dataList.get(i+1)));
                i += 2;
                resEntity.setLali2(ZhjdIotUtils.hexToOnePoint(dataList.get(i)+dataList.get(i+1)));
                i += 2;
                resEntity.setLali3(ZhjdIotUtils.hexToOnePoint(dataList.get(i)+dataList.get(i+1)));
                i+=2;
                resEntity.setStatus(dataList.get(i));
                asphaltLowTemperatureElongationResService.saveOrUpdate(resEntity);
            } else {
                throw new RenException("沥青低温延伸度数据解析异常：" + resData);
            }
        } catch (Exception e) {
            errorRecordService.saveErrorData(ZhjdIotUtils.ASPHALT_LOW_TEMPERATURE_ELONGATION,deviceId,resData);
            throw e;
//            throw new RenException("数据解析异常");
        }
    }

    /**
     * 批处理历史数据,重新进行解析过程数据
     */
    public void reparseData(){
        //获取所有数据
        List<AsphaltLowTemperatureElongationEntity> list = asphaltLowTemperatureElongationMapper.selectList(new QueryWrapper<>());
        for(AsphaltLowTemperatureElongationEntity item : list){
            List<String> dataList = ZhjdIotUtils.analyzeExperimentalData(item.getOriginalData());
            int i = 4;
            AsphaltLowTemperatureElongationEntity entity = item;
            i++;
            entity.setFlag(dataList.get(i));

            // 将16进制转换为10进制数据，不含（0x）
            // 位移量Length1,Legth2,Legth3
            i++;
            BigDecimal length1 = ZhjdIotUtils.hexToDecimalism(dataList.get(i), dataList.get(i + 1));
            entity.setLength1(length1);
            i += 2;
            BigDecimal length2 = ZhjdIotUtils.hexToDecimalism(dataList.get(i), dataList.get(i + 1));
            entity.setLength2(length2);
            i += 2;
            BigDecimal length3 = ZhjdIotUtils.hexToDecimalism(dataList.get(i), dataList.get(i + 1));
            entity.setLength3(length3);
            i += 2;
            //延伸速率SPEED。 取值：10  50 表示为10mm/min 和50mm/min
            Integer speed1 = Integer.parseInt(dataList.get(i), 16);
            entity.setSpeed1(speed1);
            i++;
            Integer speed2 = Integer.parseInt(dataList.get(i), 16);
            entity.setSpeed2(speed2);
            i++;
            //温度 当前温度值CURR_TEMP，高8位在前。2字节有符号整形，取值-32768~+32767，含1位小数 TODO:正负数处理
            //TODO
            entity.setCurrTemp(ZhjdIotUtils.hexToDecimalism(dataList.get(i), dataList.get(i + 1)));
            //设定的温度值SET_TEMP，高8位在前。2字节有符号整形，取值-32768~+32767，含1位小数。
            //TODO
            i += 2;
            entity.setSetTemp(ZhjdIotUtils.hexToDecimalism(dataList.get(i), dataList.get(i + 1)));
            updateById(entity);
        }
    }
    /**
     * 绑定材料
     * @param asphaltLowTemperatureElongationRes
     */
    public void changeSample(AsphaltLowTemperatureElongationResEntity asphaltLowTemperatureElongationRes){
        //更新试验结果表
        asphaltLowTemperatureElongationResService.updateById(asphaltLowTemperatureElongationRes);
        //查询试验过程数据
        List<AsphaltLowTemperatureElongationEntity> processList = list(new LambdaQueryWrapper<AsphaltLowTemperatureElongationEntity>().eq(AsphaltLowTemperatureElongationEntity::getResId,asphaltLowTemperatureElongationRes.getId()));
        if(CollectionUtil.isNotEmpty(processList)){
            for(AsphaltLowTemperatureElongationEntity item : processList){
                item.setSampleId(asphaltLowTemperatureElongationRes.getSampleId());
            }
           updateBatchById(processList);
        }
    }

    /**
     * 重新解析航天科宇延度试验数据v2.X
     * @param deviceId
     * 1.解析结果数据；
     * 2.解析过程数据；
     */
    @Override
    public void reParsingData(String deviceId) {

        if(StringUtils.isBlank(deviceId)){
            return;
        }
        //1.解析结果数据；
        LambdaQueryWrapper<AsphaltLowTemperatureElongationResEntity> wrappers=new LambdaQueryWrapper<>();
        wrappers.eq(AsphaltLowTemperatureElongationResEntity::getDeviceId,deviceId);
        wrappers.isNotNull(AsphaltLowTemperatureElongationResEntity::getOriginalData);
//        wrappers.last("limit 2 ");
        List<AsphaltLowTemperatureElongationResEntity> resEntities = resMapper.selectList(wrappers);
        if(CollUtil.isEmpty(resEntities)){
            return;
        }
        for(AsphaltLowTemperatureElongationResEntity resEntity:resEntities) {
            String originalData = resEntity.getOriginalData();
            List<String> dataList = ZhjdIotUtils.analyzeExperimentalData(originalData);
            int i = 5;
            resEntity.setLength1(new BigDecimal(Integer.parseInt(dataList.get(i) + dataList.get(i + 1), 16)));
            i += 2;
            resEntity.setLength2(new BigDecimal(Integer.parseInt(dataList.get(i) + dataList.get(i + 1), 16)));
            i += 2;
            resEntity.setLength3(new BigDecimal(Integer.parseInt(dataList.get(i) + dataList.get(i + 1), 16)));
            i += 2;
            resEntity.setLali1(ZhjdIotUtils.hexToOnePoint(dataList.get(i) + dataList.get(i + 1)));
            i += 2;
            resEntity.setLali2(ZhjdIotUtils.hexToOnePoint(dataList.get(i) + dataList.get(i + 1)));
            i += 2;
            resEntity.setLali3(ZhjdIotUtils.hexToOnePoint(dataList.get(i) + dataList.get(i + 1)));
            i+=2;
            resEntity.setStatus(dataList.get(i));
            resMapper.updateById(resEntity);
        }
        //解析过程数据；
        Set<String> resIds = resEntities.stream().map(AsphaltLowTemperatureElongationResEntity::getId).collect(Collectors.toSet());
        LambdaQueryWrapper<AsphaltLowTemperatureElongationEntity> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(AsphaltLowTemperatureElongationEntity::getFlag,"01");
        wrapper.in(AsphaltLowTemperatureElongationEntity::getResId,resIds);
        wrapper.isNotNull(AsphaltLowTemperatureElongationEntity::getOriginalData);
        List<AsphaltLowTemperatureElongationEntity> entities = baseMapper.selectList(wrapper);
        if(CollUtil.isEmpty(entities)){
            return;
        }
        for(AsphaltLowTemperatureElongationEntity entity:entities) {
            String originalData = entity.getOriginalData();
            List<String> dataList = ZhjdIotUtils.analyzeExperimentalData(originalData);
            int i = 5;
            entity.setFlag(dataList.get(i));
            i++;
            BigDecimal length1 = ZhjdIotUtils.hexToTwoPoint(dataList.get(i) + dataList.get(i + 1));
            entity.setLength1(length1);
            i += 2;
            BigDecimal length2 = ZhjdIotUtils.hexToTwoPoint(dataList.get(i) + dataList.get(i + 1));
            entity.setLength2(length2);
            i += 2;
            BigDecimal length3 = ZhjdIotUtils.hexToTwoPoint(dataList.get(i) + dataList.get(i + 1));
            entity.setLength3(length3);
            i+=2;
            //延伸速率SPEED。 取值：10  50 表示为10mm/min 和50mm/min
            Integer speed1 = Integer.parseInt(dataList.get(i), 16);
            entity.setSpeed1(speed1);
            i++;
            //温度 当前温度值CURR_TEMP，高8位在前。2字节有符号整形，取值-32768~+32767，含2位小数 TODO:正负数处理
            //TODO
            entity.setCurrTemp(ZhjdIotUtils.hexToTwoPoint(dataList.get(i) + dataList.get(i + 1)));
            //设定的温度值SET_TEMP，高8位在前。2字节有符号整形，取值-32768~+32767，含2位小数。
            //TODO
            i += 2;
            entity.setSetTemp(ZhjdIotUtils.hexToTwoPoint(dataList.get(i) + dataList.get(i + 1)));
            //拉力瞬时值F1,F2,F3含一位小数；
            i += 2;
            entity.setLali1(ZhjdIotUtils.hexToOnePoint(dataList.get(i) + dataList.get(i + 1)));
            i += 2;
            entity.setLali2(ZhjdIotUtils.hexToOnePoint(dataList.get(i) + dataList.get(i + 1)));
            i += 2;
            entity.setLali3(ZhjdIotUtils.hexToOnePoint(dataList.get(i) + dataList.get(i + 1)));
            //仪器状态
            i++;
            entity.setStatus(dataList.get(i));
            baseMapper.updateById(entity);
        }

    }

    /**
     * 低温延度仪 -- 北京中科建仪电子科技有限公司
     * @param resData
     * @param deviceId
     */
    @Override
    @Transactional
    public void parsingDataBjzkjydz(String resData, String deviceId) {
        System.out.println("北京中科建仪电子科技有限公司低温延度仪：" + resData);
        DuctilityData instrumentData = (DuctilityData) AsphaltProtocolParserUtils.parseDataFrame(resData);
        if(instrumentData != null){
            if("试验状态".equals(instrumentData.getStatus())){
                AsphaltLowTemperatureElongationEntity entity = new AsphaltLowTemperatureElongationEntity();
                entity.setDeviceId(deviceId);
                entity.setStatus("01");
                entity.setLength1(new BigDecimal(instrumentData.getData1()).setScale(2,RoundingMode.HALF_UP));
                entity.setLength2(new BigDecimal(instrumentData.getData2()).setScale(2,RoundingMode.HALF_UP));
                entity.setLength3(new BigDecimal(instrumentData.getData3()).setScale(2,RoundingMode.HALF_UP));
                entity.setSpeed1(instrumentData.getMotorSpeed());
                entity.setCurrTemp(new BigDecimal(instrumentData.getTemperature()).divide(BigDecimal.valueOf(10)).setScale(1,
                        RoundingMode.HALF_UP));
                entity.setCreateTime(new Date());
                entity.setOriginalData(resData);
                baseMapper.insert(entity);
            }else if("非试验状态".equals(instrumentData.getStatus())){
                AsphaltLowTemperatureElongationResEntity entity = new AsphaltLowTemperatureElongationResEntity();
                entity.setDeviceId(deviceId);
                entity.setStatus("00");
                entity.setLength1(new BigDecimal(instrumentData.getData1()).setScale(2,RoundingMode.HALF_UP));
                entity.setLength2(new BigDecimal(instrumentData.getData2()).setScale(2,RoundingMode.HALF_UP));
                entity.setLength3(new BigDecimal(instrumentData.getData3()).setScale(2,RoundingMode.HALF_UP));
                entity.setSpeed1(instrumentData.getMotorSpeed());
                entity.setCurrTemp(new BigDecimal(instrumentData.getTemperature()).divide(BigDecimal.valueOf(10)).setScale(1,RoundingMode.HALF_UP));
                entity.setCreateTime(new Date());
                entity.setOriginalData(resData);
                resMapper.insert(entity);
                //修改试验表的res_id
                LambdaUpdateWrapper<AsphaltLowTemperatureElongationEntity> AaphaltLowTemperatureElongationEntityLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
                AaphaltLowTemperatureElongationEntityLambdaUpdateWrapper.eq(AsphaltLowTemperatureElongationEntity::getDeviceId, deviceId);
                AaphaltLowTemperatureElongationEntityLambdaUpdateWrapper.set(AsphaltLowTemperatureElongationEntity::getResId, entity.getId());
                baseMapper.update(null,AaphaltLowTemperatureElongationEntityLambdaUpdateWrapper);
            }

        }
    }


    /**
     * 云检科技 - 低温延度仪
     */
    @Override
    @Transactional
    public void parsingDataYjkj(String resData, String deviceId) {
        System.out.println("云检科技 - 低温延度仪：" + resData);
        DuctilityDataYjkj instrumentData = (DuctilityDataYjkj)DuctilityYjkjDataParserUtils.parse(resData);
        if(instrumentData != null){
            if("0".equals(instrumentData.getDataFlag())){
                DuctilityRealTimeData realTimeData = (DuctilityRealTimeData)instrumentData;
                AsphaltLowTemperatureElongationEntity entity = new AsphaltLowTemperatureElongationEntity();
                entity.setDeviceId(deviceId);
                if(0 == realTimeData.getFlag()){
                    entity.setFlag("00");
                }else{
                    entity.setFlag("01");
                }
                entity.setLength1(new BigDecimal(realTimeData.getLength1()));
                entity.setLength2(new BigDecimal(realTimeData.getLength2()));
                entity.setLength3(new BigDecimal(realTimeData.getLength3()));
                entity.setSpeed1((int) realTimeData.getSpeed());
                entity.setCurrTemp(new BigDecimal(realTimeData.getCurrentTemp()).setScale(1, RoundingMode.HALF_UP));
                entity.setSetTemp(new BigDecimal(realTimeData.getSetTemp()).setScale(1, RoundingMode.HALF_UP));
                entity.setCreateTime(new Date());
                entity.setOriginalData(resData);
                baseMapper.insert(entity);
            } else {
                DuctilityFinalResult finalResult = (DuctilityFinalResult)instrumentData;
                AsphaltLowTemperatureElongationResEntity entity = new AsphaltLowTemperatureElongationResEntity();
                entity.setDeviceId(deviceId);
                entity.setLength1(new BigDecimal(finalResult.getLength1()));
                entity.setLength2(new BigDecimal(finalResult.getLength2()));
                entity.setLength3(new BigDecimal(finalResult.getLength3()));
                entity.setSpeed1((int) finalResult.getSpeed());
                entity.setCurrTemp(new BigDecimal(finalResult.getCurrentTemp()));
                entity.setSetTemp(new BigDecimal(finalResult.getSetTemp()));
                entity.setCreateTime(new Date());
                entity.setOriginalData(resData);
                resMapper.insert(entity);
                //修改试验表的res_id
                LambdaUpdateWrapper<AsphaltLowTemperatureElongationEntity> AaphaltLowTemperatureElongationEntityLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
                AaphaltLowTemperatureElongationEntityLambdaUpdateWrapper.eq(AsphaltLowTemperatureElongationEntity::getDeviceId, deviceId);
                AaphaltLowTemperatureElongationEntityLambdaUpdateWrapper.set(AsphaltLowTemperatureElongationEntity::getResId, entity.getId());
                baseMapper.update(null,AaphaltLowTemperatureElongationEntityLambdaUpdateWrapper);
            }

        }
    }
}
